#include "dyn_specialFunctions_hankel.h"

Hankel::Hankel(int _kind, double _order)
{
    setKind(_kind);
    setOrder(_order);
}

d_complex Hankel::operator ()(const d_complex z)
{
    // 1 and i
    d_complex coefficient(1.0,0.0), i(0.0,1.0);
    double Pi = 3.1415926535897932384626433832795028841971693993751058;

    // Do something if order is negative.
    if (order < 0.0)
    {
        if (kind==1){coefficient*=exp(Pi*fabs(order)*i);}
        if (kind==2){coefficient*=exp(-Pi*fabs(order)*i);}
    }

    // Input values.
    double zr = real(z);
    double zi = imag(z);
    double nu = fabs(order);
    int kode = 1;
    int N = 1;

    // Output values
    double cyr,cyi;
    int nz,ierr;

    // External function call
    zbesh_(&zr,&zi,&nu,&kode,&kind,&N,&cyr,&cyi,&nz,&ierr);

    d_complex answer(cyr,cyi);

    return coefficient*answer;
}
